package com.treasure.hunt.api

import com.module.lemlin.mode.SubscribeListener
import com.treasure.hunt.entity.VideoEndResponse
import com.treasure.hunt.entity.VideoTypeResponse
import io.reactivex.rxjava3.disposables.Disposable
import com.treasure.hunt.api.subscribe.subscribe
import rxhttp.RxHttp

/**
 * 视频观看记录添加
 * */
fun videoType(
    maps: Map<String, Any?>, listener: SubscribeListener<VideoTypeResponse>
): Disposable = subscribe(
    RxHttp.postForm("/api/video/video_type")
        .addAll(maps.filter { it.value != null })
        .asClass(VideoTypeResponse::class.java)
    , listener
)

/**
 * 完成观看视频
 * */
fun videoEnd(
    videoLogId: String, listener: SubscribeListener<VideoEndResponse>
): Disposable = subscribe(
    RxHttp.postForm("/api/video/end_video")
        .add("video_log_id", videoLogId)
        .asClass(VideoEndResponse::class.java)
    , listener
)

/**
 * 无奖励视频
 * 视频类型:1=开屏,2=banner,3=信息流,4=插屏,5=激励广告,6=全屏广告
 * */
fun videoNoReward(
    advertisementType: Int, listener: SubscribeListener<VideoTypeResponse>
): Disposable = subscribe(
    RxHttp.postForm("/api/video/no_reward")
        //.setAssemblyEnabled(false)
        .add("advertisement_type", advertisementType)
        .asClass(VideoTypeResponse::class.java)
    , listener
)